home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / minix / up1510b.tgz / up1510b / src / kernel / tty.h < prev    next >
Text File  |  1990-07-15  |  9KB  |  175 lines

  1. #define NR_CONS            1    /* how many consoles can system handle */
  2.  
  3. #if (CHIP == M68000)
  4. #define CONSOLE            0    /* line number for console */
  5. #define SERIAL1           1    /* line number for serial port */
  6. #define OPERATOR        (-1)    /* handle CTRL-ALT-PFX sequences */
  7. #endif
  8.  
  9. #define    NR_RS_LINES       1    /* how many rs232 terminals can system handle*/
  10. #define TTY_IN_BYTES    1000    /* input queue size */
  11. #define TTY_RAM_WORDS    320    /* ram buffer size */
  12. #define TTY_BUF_SIZE     256    /* unit for copying to/from queues */
  13. #define TAB_SIZE           8    /* distance between tabs */
  14. #define TAB_MASK          07    /* mask for tty_column when tabbing */
  15. #define WORD_MASK     0xFFFF    /* mask for 16 bits */
  16. #define OFF_MASK      0x000F    /* mask for  4 bits */
  17. #define MAX_OVERRUN      500    /* size of overrun input buffer */
  18. #define MAX_ESC_PARMS      2    /* number of escape sequence params allowed */
  19.  
  20. #define ERASE_CHAR      '\b'    /* default erase character */
  21. #define KILL_CHAR        '@'    /* default kill character */
  22. #define INTR_CHAR (char)0177    /* default interrupt character */
  23. #define QUIT_CHAR (char) 034    /* default quit character */
  24. #define XOFF_CHAR (char) 023    /* default x-off character (CTRL-S) */
  25. #define XON_CHAR  (char) 021    /* default x-on character (CTRL-Q) */
  26. #define EOT_CHAR  (char) 004    /* CTRL-D */
  27.  
  28. /*
  29.  * This MARKER is used as an unambiguous flag for an unescaped end of
  30.  * file character.  It is meaningful only in cooked mode.  0200 should
  31.  * never be used in cooked mode, since that is supposed to be used only
  32.  * for 7-bit ASCII.  Be careful that code only checks
  33.  * for MARKER in cooked mode.  This kludge is needed because
  34.  * chars are stored in char arrays, so there's no way to have a
  35.  * completely out of band value.
  36.  */
  37. #define MARKER   (char) 0200    /* non-escaped CTRL-D stored as MARKER */
  38. #define SCODE1            71    /* scan code for Home on numeric pad */
  39. #define SCODE2            81    /* scan code for PgDn on numeric pad */
  40. #define DEL_CODE   (char) 83    /* DEL for use in CTRL-ALT-DEL reboot */
  41. #define ESC       (char) 033    /* escape */
  42. #define BRACKET          '['    /* Part of the ESC [ letter escape seq */
  43.  
  44. /* The following macro is introduced since PC's must enable their interrupt
  45.  * controller, whereas Atari's don't. Since this happens on several places I
  46.  * found a macro cleaner than zillions of #ifdef's
  47.  */
  48. #if (CHIP == M68000)
  49. #define    INT_CTL_ENABLE    
  50. #else
  51. #define    INT_CTL_ENABLE  port_out(INT_CTL, ENABLE)
  52.             /* re-enable 8259A controller */
  53. #endif
  54.  
  55. #if (CHIP == M68000)
  56. #define F1                1    /* scan code for function key F1 */
  57. #define F2                2    /* scan code for function key F2 */
  58. #define F3                3    /* scan code for function key F3 */
  59. #define F4                4    /* scan code for function key F4 */
  60. #define F5                5    /* scan code for function key F5 */
  61. #define F6                6    /* scan code for function key F6 */
  62. #define F7                7    /* scan code for function key F7 */
  63. #define F8                8    /* scan code for function key F8 */
  64. #define F9                9    /* scan code for function key F9 */
  65. #define F10               10    /* scan code for function key F10 */
  66. #else
  67. #define F1                59    /* scan code for function key F1 */
  68. #define F2                60    /* scan code for function key F2 */
  69. #define F3                61    /* scan code for function key F3 */
  70. #define F4                62    /* scan code for function key F4 */
  71. #define F5                63    /* scan code for function key F5 */
  72. #define F6                64    /* scan code for function key F6 */
  73. #define F7                65    /* scan code for function key F7 */
  74. #define F8                66    /* scan code for function key F8 */
  75. #define F9                67    /* scan code for function key F9 */
  76. #define F10               68    /* scan code for function key F10 */
  77. #endif
  78. #define TOP_ROW           14    /* codes below this are shifted if CTRL */
  79.  
  80. #define IBM_PC           1    /* Standard IBM keyboard */
  81. #define OLIVETTI       2    /* Olivetti keyboard     */
  82. #define DUTCH_EXT       3    /* Dutch extended IBM keyboard */
  83. #define US_EXT           4    /* U.S. extended keyboard */
  84. #define NR_SCAN_CODES   0x69    /* Number of scan codes */
  85.  
  86. EXTERN struct tty_struct {
  87.   /* Input queue.  Typed characters are stored here until read by a program. */
  88.   char tty_inqueue[TTY_IN_BYTES];    /* array used to store the characters */
  89.   char *tty_inhead;        /* pointer to place where next char goes */
  90.   char *tty_intail;        /* pointer to next char to be given to prog */
  91.   int tty_incount;        /* # chars in tty_inqueue */
  92.   int tty_lfct;            /* # line feeds in tty_inqueue */
  93.  
  94.   /* Output section. */
  95.   int tty_ramqueue[TTY_RAM_WORDS];    /* buffer for video RAM */
  96.   int tty_rwords;        /* number of WORDS (not bytes) in outqueue */
  97.   int tty_org;            /* location in RAM where 6845 base points */
  98.   int tty_vid;            /* current position of cursor in video RAM */
  99.   char tty_esc_state;        /* 0=normal, 1=ESC, 2=ESC[ */
  100.   char tty_esc_intro;        /* Distinguishing character following ESC */
  101.   int tty_esc_parmv[MAX_ESC_PARMS];    /* list of escape parameters */
  102.   int *tty_esc_parmp;        /* pointer to current escape parameter */
  103. #if (CHIP != M68000)
  104.   int tty_attribute;        /* current attribute byte << 8 */
  105. #endif
  106.   int (*tty_devstart)();    /* routine to start actual device output */
  107.  
  108.   /* Terminal parameters and status. */
  109.   int tty_mode;            /* terminal mode set by IOCTL */
  110.   int tty_speed;        /* low byte is ispeed; high byte is ospeed */
  111.   int tty_column;        /* current column number (0-origin) */
  112.   int tty_row;            /* current row (0 at top of screen) */
  113.   char tty_busy;        /* 1 when output in progress, else 0 */
  114.   char tty_escaped;        /* 1 when '\' just seen, else 0 */
  115.   char tty_inhibited;        /* 1 when CTRL-S just seen (stops output) */
  116.   char tty_makebreak;        /* 1 for terminals that interrupt twice/key */
  117.   char tty_waiting;        /* 1 when output process waiting for reply */
  118.  
  119.   /* User settable characters: erase, kill, interrupt, quit, x-on; x-off. */
  120.   char tty_erase;        /* char used to erase 1 char (init ^H) */
  121.   char tty_kill;        /* char used to erase a line (init @) */
  122.   char tty_intr;        /* char used to send SIGINT  (init DEL) */
  123.   char tty_quit;        /* char used for core dump   (init CTRL-\) */
  124.   char tty_xon;            /* char used to start output (init CTRL-Q)*/
  125.   char tty_xoff;        /* char used to stop output  (init CTRL-S) */
  126.   char tty_eof;            /* char used to stop output  (init CTRL-D) */
  127.  
  128.   /* Information about incomplete I/O requests is stored here. */
  129.   char tty_incaller;        /* process that made the call (usually FS) */
  130.   char tty_inproc;        /* process that wants to read from tty */
  131.   char *tty_in_vir;        /* virtual address where data is to go */
  132.   int tty_inleft;        /* how many chars are still needed */
  133.   char tty_otcaller;        /* process that made the call (usually FS) */
  134.   char tty_outproc;        /* process that wants to write to tty */
  135.   char *tty_out_vir;        /* virtual address where data comes from */
  136.   phys_bytes tty_phys;        /* physical address where data comes from */
  137.   int tty_outleft;        /* # chars yet to be copied to tty_outqueue */
  138.   int tty_cum;            /* # chars copied to tty_outqueue so far */
  139.   int tty_pgrp;            /* slot number of controlling process */
  140.  
  141.   /* Miscellaneous. */
  142.   int tty_ioport;        /* I/O port number for this terminal */
  143.  
  144. } tty_struct[NR_CONS+NR_RS_LINES];
  145.  
  146.  
  147. /* Values for the fields. */
  148. #define NOT_ESCAPED        0    /* previous character on this line not '\' */
  149. #define ESCAPED            1    /* previous character on this line was '\' */
  150. #define RUNNING            0    /* no CRTL-S has been typed to stop the tty */
  151. #define STOPPED            1    /* CTRL-S has been typed to stop the tty */
  152. #define INACTIVE           0    /* the tty is not printing */
  153. #define BUSY               1    /* the tty is printing */
  154. #define ONE_INT            0    /* regular terminals interrupt once per char */
  155. #define TWO_INTS           1    /* IBM console interrupts two times per char */
  156. #define NOT_WAITING        0    /* no output process is hanging */
  157. #define WAITING            1    /* an output process is waiting for a reply */
  158. #define COMPLETED          2    /* output done; send a completion message */
  159.  
  160. EXTERN char tty_driver_buf[2*MAX_OVERRUN+4]; /* driver collects chars here */
  161. #define tty_buf_count(p) (((int *)(p))[0])
  162. #define tty_buf_